package com.wenwan.manage.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wenwan.manage.service.FeedBackService;
import com.wenwan.manage.setting.DefaultValue;

import javax.annotation.Resource;

/**
 * 举报
 * 
 * @author Admin
 *
 */
@RequestMapping("/feedback")
@Controller
public class FeedBackController {

	@Autowired
	private FeedBackService feedBackService;

	/**
	 * 创建反馈
	 */
	@ResponseBody
	@RequestMapping(value = "/create", method = { RequestMethod.POST })
	public Map<String,Object> create(@RequestParam(required = true) String phone,
			@RequestParam(required = true) String content,
			@RequestParam(required = false, defaultValue = DefaultValue.ARRAY_LIST_NULL) String images) {
		return feedBackService.create(phone, content, images);
	}

	/**
	 * 更新反馈，一般不使用
	 * 
	 * @param id
	 * @param phone
	 * @param content
	 * @param images
	 * @return
	 */
	public Map<String, Object> update(@RequestParam(required = true) String id,
			@RequestParam(required = true) String phone, @RequestParam(required = true) String content,
			@RequestParam(required = false, defaultValue = DefaultValue.ARRAY_LIST_NULL) String images) {
		// DataToObject<Boolean> dto = feedBackService.update(id,phone,content,images);
		return null;
	}

	/**
	 * 删除反馈
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/delete/by/id", method = { RequestMethod.POST })
	public Map<String,Object> deleteById(@RequestParam(required = true) String id) {
		return feedBackService.deleteById(id);
	}

	/**
	 * 查询所有
	 * 
	 * @param currentPage
	 *            当前页的值
	 * @param pageSize
	 *            每页显示条数
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/select/all", method = { RequestMethod.GET })
	public Map<String,Object> selectAll(
			@RequestParam(required = false, defaultValue = DefaultValue.CURRENT_PAGE) Integer currentPage,
			@RequestParam(required = false, defaultValue = DefaultValue.PAGE_SIZE) Integer pageSize) {
		return feedBackService.selectAll(currentPage, pageSize);
	}

	/**
	 * 查询单个
	 * 
	 * @param id
	 *            唯一标识
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/select/one/by/id", method = { RequestMethod.GET })
	public Map<String,Object> selectOneById(@RequestParam(required = true) String id) {
		return feedBackService.selectOneById(id);
	}

}
